﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AMS
{
    public partial class frmAMS : Form
    {
        FormManager formManager;

        public frmAMS()
        {
            InitializeComponent();

            formManager = new FormManager();
            formManager.MDIParent = this;
        }

        #region Standard events
        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (BaseForm childForm in MdiChildren)
            {
                childForm.DestroyForm(childForm);
            }
        }
        #endregion

        #region Custom Events
        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void toolOpenRequest_Click(object sender, EventArgs e)
        {
            try
            {
                frmLoadRequest loadRequest = new frmLoadRequest();
                loadRequest.MdiParent = this;
                loadRequest.Show();
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                formManager.ShowForm(FormTypes.AboutBox, -1);
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
        }

        private void Click(object sender, EventArgs e)
        {
            Cursor defaultCursor = Cursor;

            try
            {
                
                Cursor = Cursors.WaitCursor;

                ToolStripMenuItem currentControl = (ToolStripMenuItem)sender;
                switch (currentControl.Name)
                {
                    case "toolNewRequest":
                        formManager.ShowForm(FormTypes.Request, -1);
                        break;
                    case "toolOpenRequest":
                        formManager.ShowForm(FormTypes.LoadRequest, -1);
                        break;
                    case "analysisMethodsToolStripMenuItem":
                        formManager.ShowForm(FormTypes.AnalysisMethod, -1);
                        break;
                    case "aboutToolStripMenuItem":
                        formManager.ShowForm(FormTypes.AboutBox, -1);
                        break;
                    //case "toolSearchRequest":
                    //    formManager.ShowForm(FormTypes.SearchRequest, -1);
                    //    break;
                    case "requestorsToolStripMenuItem":
                        formManager.ShowForm(FormTypes.Requestors, -1);
                        break;
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
            finally
            {
                Cursor = defaultCursor;
            }

        }
        #endregion
    }
}
